﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//f(11)返回4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class SolGoodFeature232
{

    public int NumsofOne(int num)
    {
        int sum = 0;

        for (int i = 1; i <= num; i++) {


            sum += Mychecked(i);




        }



        return sum;
    }

    public int Mychecked(int num) {
        int sum = 0;
        //Console.WriteLine("num:  "+num);


        while ( num / 10>0)//num大于10
        {

            if (num % 10 == 1) { //更新后的个位

                sum += 1;
            }
            num /= 10;

        }

        if (num == 1)
        {
            sum += 1;
        }
        //Console.WriteLine("sum:  " + sum);
        return sum;



}
}
class ProgramGoodFeature232
{



    static void MainGoodFeature232()
    {

        string s = Console.ReadLine();
       

        int num=int.Parse(s);

        SolGoodFeature232 sol = new SolGoodFeature232();
        int res = sol.NumsofOne(num);
        Console.WriteLine(res);




    }
}

